﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyBetImporter.DAL;
using System.Web.Security;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace MyBetImporter
{
    public class SubscriptionObject
    {

        /// <summary>
        /// Get user ranks of a given contest
        /// </summary>
        /// <param name="dbContext">Database connection</param>
        /// <param name="contestId">Contest identifier</param>
        /// <returns></returns>
        public static int GetSubscriptionId(ParieurProDBEntities dbContext, Guid userId)
        {

            var queryBets = (from subscription in dbContext.Subscriptions
                             where (subscription.UserId == userId)
                             select subscription.SubscriptionId);

            int subscriptionId = queryBets.First();
            return subscriptionId;
        }

        public static IList<Guid> GetUsersList(ParieurProDBEntities dbContext, int contestId)
        {

            var query = (from subscription in dbContext.Subscriptions
                             where (subscription.CustomContestId == contestId)
                             select subscription.UserId);

            IList<Guid> usersList = query.ToList();
            return usersList;
        }

    }


}